package ca.psquared.superbrixgame.states;

import ca.psquared.superbrixgame.SuperBrixGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

public class GameEndState extends BasicGameState {

    private StateBasedGame game;

    @Override
    public int getID() {
        return SuperBrixGame.GAME_END_STATE;
    }

    @Override
    public void init(GameContainer container, StateBasedGame game) throws SlickException {
        this.game = game;
    }

    @Override
    public void render(GameContainer container, StateBasedGame game, Graphics graphics) throws SlickException {
        graphics.drawString("Game Over. Press Space to restart or Esc to exit.", 200, 300);
    }

    @Override
    public void update(GameContainer container, StateBasedGame game, int delta) throws SlickException {
    }

    @Override
    public void keyPressed(int key, char c) {

        if (key == Input.KEY_SPACE) {
            game.enterState(SuperBrixGame.MAIN_GAME_STATE);
        } else if (key == Input.KEY_ESCAPE) {
            game.getContainer().exit();
        }


    }
}
